package leetcode.list;

import java.util.HashSet;

/**
 * @author mazouri
 * @create 2021-08-18 21:26
 */
public class _141_hasCycle {
    public boolean hasCycle(ListNode head) {
        HashSet<ListNode> set = new HashSet<>();

        while (head != null) {
            if (set.contains(head)) {
                return true;
            }

            set.add(head);
            head = head.next;
        }
        return false;
    }
}
